package com.disgruntledbots;

import org.andengine.opengl.texture.TextureManager;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.ui.activity.BaseGameActivity;

import android.util.Log;

public class SpriteLoader {

	BitmapTextureAtlas circleBmpAtlas;
	BitmapTextureAtlas basicBotBmpAtlas;
	BitmapTextureAtlas bombBotBmpAtlas;
	BitmapTextureAtlas empBotBmpAtlas;

	BitmapTextureAtlas squareBmpAtlas;
	BitmapTextureAtlas energyBlockBmpAtlas;
	BitmapTextureAtlas glassBlockBmpAtlas;
	BitmapTextureAtlas plasticBlockBmpAtlas;
	BitmapTextureAtlas stoneBlockBmpAtlas;

	ITextureRegion circleTxtrRegion;
	ITextureRegion basicBotTxtrRegion;
	ITextureRegion bombBotTxtrRegion;
	ITextureRegion empBotTxtrRegion;
	
	ITextureRegion squareTxtrRegion;
	ITextureRegion energyBlockTxtrRegion;
	ITextureRegion glassBlockTxtrRegion;
	ITextureRegion plasticBlockTxtrRegion;
	ITextureRegion stoneBlockTxtrRegion;
	
	public SpriteLoader(BaseGameActivity parent)
	{
		TextureManager textureManager = parent.getTextureManager();
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("sprites/bots/");
		
		circleBmpAtlas = new BitmapTextureAtlas(textureManager, 64, 64); 
		circleTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(circleBmpAtlas, parent, "player_projectile.png", 0,0);
		
		basicBotBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48); 
		basicBotTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(basicBotBmpAtlas, parent, "Basic Bot.png", 0,0);

		bombBotBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48); 
		bombBotTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(bombBotBmpAtlas, parent, "Bomb Bot.png", 0,0);
		
		empBotBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48); 
		empBotTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(empBotBmpAtlas, parent, "EMP Bot.png", 0,0);
		
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("sprites/destructableObstacles/");
		
		squareBmpAtlas = new BitmapTextureAtlas(textureManager, 64, 64);
		energyBlockBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48);
		glassBlockBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48);
		plasticBlockBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48);
		stoneBlockBmpAtlas = new BitmapTextureAtlas(textureManager, 48, 48);
		
		squareTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(squareBmpAtlas, parent, "block.png", 0,0);
		energyBlockTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(energyBlockBmpAtlas, parent, "Energy Block.png", 0,0);
		glassBlockTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(glassBlockBmpAtlas, parent, "Glass Block.png", 0,0);
		plasticBlockTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(plasticBlockBmpAtlas, parent, "Plastic Block.png", 0,0);
		stoneBlockTxtrRegion = 
				BitmapTextureAtlasTextureRegionFactory.
				createFromAsset(stoneBlockBmpAtlas, parent, "Stone Block.png", 0,0);
		
		circleBmpAtlas.load();
		basicBotBmpAtlas.load();
		bombBotBmpAtlas.load();
		empBotBmpAtlas.load();
		
		squareBmpAtlas.load();
		energyBlockBmpAtlas.load();
		glassBlockBmpAtlas.load();
		plasticBlockBmpAtlas.load();
		stoneBlockBmpAtlas.load();
	}
}
